---
title: Polyfills
description: The page outlines all the test polyfills available.
docType: Guides
docGroup: Testing
group: Polyfills
---

# Polyfills

> !Success! All the polyfills are included by default when following the
> [quickstart guide](./quickstart#setup-polyfills-and-test-matchers). This page
> is mostly for informational purposes only.

By importing the `@react-md/core/test-utils/polyfills`, all the following
polyfills will be applied. You can also manually import the specific polyfills
instead.

## matchMedia [$SOURCE](packages/core/src/test-utils/polyfills/matchMedia.ts)

```ts
import "@react-md/core/test-utils/polyfills/matchMedia";
```

This updates `window.matchMedia` to default to desktop when `typeof window.matchMedia === "undefined"`.

## ResizeObserver [$SOURCE](packages/core/src/test-utils/polyfills/ResizeObserver.ts)

```ts
import "@react-md/core/test-utils/polyfills/ResizeObserver";
```

This sets the `window.ResizeObserver` to the `ResizeObserverMock`
when it is `undefined`. See the
[ResizeObserverMock](./test-utils#resize-observer-mock) for more details.

## IntersectionObserver [$SOURCE](packages/core/src/test-utils/polyfills/IntersectionObserver.ts)

```ts
import "@react-md/core/test-utils/polyfills/IntersectionObserver";
```

This sets the `window.IntersectionObserver` to the `IntersectionObserverMock`
when it is `undefined`. See the
[IntersectionObserverMock](./test-utils#intersection-observer-mock) for more details.

## TextEncoder [$SOURCE](packages/core/src/test-utils/polyfills/TextEncoder.ts)

```ts
import "@react-md/core/test-utils/polyfills/TextEncoder";
```

This sets the `global.TextEncoder` to `node:util`
[TextEncoder](https://nodejs.org/docs/latest-v22.x/api/util.html#class-utiltextencoder)
when it is `undefined`.

## TextDecoder [$SOURCE](packages/core/src/test-utils/polyfills/TextDecoder.ts)

```ts
import "@react-md/core/test-utils/polyfills/TextDecoder";
```

This sets the `global.TextDecoder` to `node:util`
[TextDecoder](https://nodejs.org/docs/latest-v22.x/api/util.html#class-utiltextdecoder)
when it is `undefined`.

## offsetParent [$SOURCE](packages/core/src/test-utils/polyfills/offsetParent.ts)

```ts
import "@react-md/core/test-utils/polyfills/offsetParent";
```

This polyfill was added for the tree keyboard movement behavior since `offsetParent` might return the incorrect value in jsdom.

## scrollIntoView [$SOURCE](packages/core/src/test-utils/polyfills/scrollIntoView.ts)

```ts
import "@react-md/core/test-utils/polyfills/scrollIntoView";
```

This polyfill adds no-op behavior to the `HTMLElement.prototype.scrollIntoView` if it is `undefined`.
